package com.xhwl.logistics.controller;

import com.xhwl.common.pojo.ResultJson;
import com.xhwl.logistics.bo.VehicleCarportBO;
import com.xhwl.logistics.bo.input.QueryVehicleCarportBO;
import com.xhwl.logistics.converter.mapstruct.VehicleCarportConverter;
import com.xhwl.logistics.dto.query.VehicleCarportDTO;
import com.xhwl.logistics.service.IVehicleCarportService;
import com.xhwl.logistics.vo.VehicleCarportSecondVO;
import com.xhwl.logistics.vo.VehicleCarportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

//@RestController
public class VehicleCarportController {

    @Autowired
    private IVehicleCarportService vehicleCarportService;

    @Autowired
    private VehicleCarportConverter vehicleCarportConverter;

    @PostMapping("/carport/detail")
    public ResultJson<VehicleCarportVO> carPort(@RequestBody VehicleCarportDTO vehicleCarportDTO) {
        QueryVehicleCarportBO queryVehicleCarportBO = vehicleCarportConverter.vehicleCarportDTO2QueryVehicleCarportBO(vehicleCarportDTO);

        VehicleCarportBO vehicleCarportBO = vehicleCarportService.queryCarport(queryVehicleCarportBO);

        return ResultJson.successWithResult(vehicleCarportConverter.vehicleCarportBO2VehicleCarportVO(vehicleCarportBO, queryVehicleCarportBO.getParkingLotName()));
    }

    /**
     * 获取车流统计中的车位总览
     * @param vehicleCarportDTO
     * @return
     */
    @PostMapping("/carport/overview")
    public ResultJson<VehicleCarportSecondVO> carPortOverview(@RequestBody VehicleCarportDTO vehicleCarportDTO){
        QueryVehicleCarportBO queryVehicleCarportBO = vehicleCarportConverter.vehicleCarportDTO2QueryVehicleCarportBO(vehicleCarportDTO);
        VehicleCarportBO vehicleCarportBO = vehicleCarportService.queryCarport(queryVehicleCarportBO);
        return ResultJson.successWithResult(vehicleCarportConverter.toVehicleCarportSecondVO(vehicleCarportBO));
    }
}
